import axiosReq from '@/utils/axios-req'
import { useProjectInfoStore } from '@/store/projectInfo'
const BASE_URL = import.meta.env.VITE_APP_BASE_URL_SYH
/**
 * 更新追加报价
 * @param data {
  "id": 1,
  "appendPrice": 1.0,

    "supplierId": 6,
  "projectId": 6
}
 * @returns 
 */
export const updateAppendPrice = (data: any) => {
  const projectId = useProjectInfoStore().projectInfo.id
  return axiosReq({
    baseURL: BASE_URL,
    url: `/cloud/pbgl/supplierAppendInfo/updateAppendPrice`,
    method: 'POST',
    data: {
      ...data,
      projectId
    },
    showMsg: true
  })
}

/**
 * 新增追加报价
 * @param data 
 * {
  "projectId": 1,
  "appendPrice": 1.0
  }
 * @returns 
 */
export const savaAppendPrice = (data: any) => {
  const projectId = useProjectInfoStore().projectInfo.id
  return axiosReq({
    baseURL: BASE_URL,
    url: `/cloud/pbgl/supplierAppendInfo/sava`,
    method: 'POST',
    data: {
      ...data,
      projectId
    },
    showMsg: true
  })
}

/**
 * *追加报价信息-删除
 * @param data {
  "id": 1
}
 * @returns 
 */
export const deleteAppendPrice = (data: any) => {
  const projectId = useProjectInfoStore().projectInfo.id
  return axiosReq({
    baseURL: BASE_URL,
    url: `/cloud/pbgl/supplierAppendInfo/delete`,
    method: 'POST',
    data: {
      ...data,
      projectId
    },
    showMsg: true
  })
}
/**
 * 更新评审报价
 * @param data {
  "reviewPrice": 12.0,
  "id": 1
}
 * @returns 
 */
export const updateReviewPrice = (data: any) => {
  return axiosReq({
    baseURL: BASE_URL,
    url: `/cloud/pbgl/supplierInfo/updateReviewPrice`,
    method: 'POST',
    data,
    showMsg: true
  })
}
/**
 * 更新项目负责人
 * @param data {
  "projectManager": "张三",
  "id": 1
}
 * @returns 
 */
export const updateProjectManager = (data: any) => {
  return axiosReq({
    baseURL: BASE_URL,
    url: `/cloud/pbgl/supplierInfo/updateProjectManager`,
    method: 'POST',
    data,
    showMsg: true
  })
}

/**
 * 更新工期
 * @param data
 * @returns
 */
export const updateDuration = (data: any) => {
  return axiosReq({
    baseURL: BASE_URL,
    url: `/cloud/pbgl/supplierInfo/updateDuration`,
    method: 'POST',
    data,
    showMsg: true
  })
}
// 更新质量
export const updateQuality = (data: any) => {
  return axiosReq({
    baseURL: BASE_URL,
    url: `/cloud/pbgl/supplierInfo/updateQuality`,
    method: 'POST',
    data,
    showMsg: true
  })
}
/**
 * 更新投标报价
 * @param data {
  "bidPrice": 12.0,
  "id": 1
}
 * @returns 
 */
export const updateBidPrice = (data: any) => {
  return axiosReq({
    baseURL: BASE_URL,
    url: `/cloud/pbgl/supplierInfo/updateBidPrice`,
    method: 'POST',
    data,
    showMsg: true
  })
}

/**
 * 供应商附件-列表
 * @param data {
  "supplierId": 1,
  "pageNo": 1,
  "pageSize": 10
}
 * @returns
 */
export const supplierFileInfoList = (data: any) => {
  const projectId = useProjectInfoStore().projectInfo.id
  return axiosReq({
    baseURL: BASE_URL,
    url: `/cloud/pbgl/supplierFileInfo/list`,
    method: 'POST',
    data: {
      ...data,
      projectId
    }
  })
}

/**
 * 供应商信息-单位确认
 * @param data
 * @returns
 */
export const confirmUnit = (data: any) => {
  return axiosReq({
    baseURL: BASE_URL,
    url: `/cloud/pbgl/supplierInfo/confirmUnit`,
    method: 'POST',
    data,
    showMsg: true
  })
}

/**
 * 供应商信息-OA获取
 * @param data  projectId=1
 * @returns
 */
export const getOASuppliers = (params: any) => {
  return axiosReq({
    baseURL: BASE_URL,
    url: `/cloud/pbgl/supplierInfo/getOASuppliers`,
    method: 'GET',
    params,
    showMsg: true
  })
}

/**
 * 供应商信息-列表
 * @param data {
  "supplierName": "",
  "projectId": 1,

    "unitConfirm": 0,

  "pageNo": 1,
  "pageSize": 10
}
 * @returns 
 */
export const supplierInfoList = (data: any) => {
  const projectId = useProjectInfoStore().projectInfo.id
  return axiosReq({
    baseURL: BASE_URL,
    url: `/cloud/pbgl/supplierInfo/list`,
    method: 'POST',
    data: {
      ...data,
      projectId
    }
  })
}

/**
 * 供应商附件-批量上传
 * @param data {
 * file
 * projectId
 * }
 * @returns
 */
export const uploadBatchFile = (data: any) => {
  return axiosReq({
    baseURL: BASE_URL,
    url: `/cloud/pbgl/supplierFileInfo/uploadBatchFile`,
    method: 'POST',
    data
  })
}

/**
 * 供应商附件-删除
 * @param data {
  "id": 29
}
 * @returns 
 */
export const supplierFileInfoDelete = (data: any) => {
  return axiosReq({
    baseURL: BASE_URL,
    url: `/cloud/pbgl/supplierFileInfo/delete`,
    method: 'POST',
    data,
    showMsg: true
  })
}

/**
 * 供应商附件-下载
 * @param data {
  "id": 29
}
 * @returns 
 */
export const supplierFileInfoDownload = (params: any) => {
  return axiosReq({
    baseURL: BASE_URL,
    url: `/cloud/pbgl/supplierFileInfo/download`,
    method: 'POST',
    params,
    responseType: 'blob'
  })
}

/**
 * 供应商信息-批量确认
 * @param data {
  "unitConfirm": 1
}
 * @returns 
 */
export const batchConfirm = () => {
  const projectId = useProjectInfoStore().projectInfo.id
  return axiosReq({
    baseURL: BASE_URL,
    url: `/cloud/pbgl/supplierInfo/batchConfirmUnit`,
    method: 'POST',
    data: {
      projectId
    },
    showMsg: true
  })
}

/**
 * 供应商信息-批量取消确认
 * @param data {
  "unitConfirm": 0
}
 * @returns 
 */
export const batchCancelConfirm = () => {
  const projectId = useProjectInfoStore().projectInfo.id
  return axiosReq({
    baseURL: BASE_URL,
    url: `/cloud/pbgl/supplierInfo/batchUnConfirmUnit`,
    method: 'POST',
    data: {
      projectId
    },
    showMsg: true
  })
}
